<?php
use Illuminate\Database\Eloquent\SoftDeletingTrait;
class Products extends Eloquent{
	protected $guarded  = array("id");
	
	use SoftDeletingTrait;

    protected $dates = ['deleted_at'];
    
    public function ext()
    {
    	return $this->hasOne('ProductExts','product_id');
    }
    
    public function images()
    {
    	return $this->hasMany('ProductImages','product_id');
    }
    
    public function sizes()
    {
    	return $this->hasMany('ProductSizes','product_id');
    }
    
    public function colors()
    {
    	return $this->hasMany('ProductColors','product_id');
    }
    
    public static function fullProduct($id){
    	 $product = Products::with('ext','sizes','colors')
    	 				  ->with(array('images'=>function($subquery){
    	 				  	 $subquery->orderBy('order', 'asc');
    	                  }))
    	                  ->withTrashed()->find($id);
    	 return $product;
    }
}